package com.example.scugroup8.controller;

import com.example.scugroup8.service.impl.DataServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/date")
@Api(value = "(Data)管理", tags = "(Data)管理接口API")
@ApiResponses({
        @ApiResponse(code = 400, message = "请求参数不完整或者错误"),
        @ApiResponse(code = 404, message = "找不到页面"),
        @ApiResponse(code = 405, message = "请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code = 406, message = "页面地址和接口名冲突"),
        @ApiResponse(code = 415, message = "请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code = 500, message = "后台服务逻辑错误")
})
public class DataController {
    @Resource
    private DataServiceImpl dataService;

    @RequestMapping(value = "/userCount", method = RequestMethod.GET)
    @ApiOperation(value = "- 当前注册用户数量（数字", notes = "- 当前注册用户数量（数字")
    public Map<String, Object> userCount() {
        return dataService.userCount();
    }

    @RequestMapping(value = "/scanCount", method = RequestMethod.GET)
    @ApiOperation(value = "- 当前完成扫描任务总数量（数字", notes = "- 当前完成扫描任务总数量（数字")
    public Map<String, Object> scanCount() {
        return dataService.scanCount();
    }

    @RequestMapping(value = "/everyCheckCount", method = RequestMethod.GET)
    @ApiOperation(value = "当前完成扫描任务总数量（数字- 各种扫描任务分布比例（饼状图，柱状图，都可以", notes = "当前完成扫描任务总数量（数字- 各种扫描任务分布比例（饼状图，柱状图，都可以")
    public Map<String, Object> everyCheckCount() {
        return dataService.everyCheckCount();
    }

    @RequestMapping(value = "/serviceCheck", method = RequestMethod.GET)
    @ApiOperation(value = "- service检测中符合规则的与不符合规则的对比柱状图service_result字段", notes = "- service检测中符合规则的与不符合规则的对比柱状图service_result字段")
    public Map<String, Object> serviceCheck() {
        return dataService.serviceCheck();
    }

    @RequestMapping(value = "/policyCheck", method = RequestMethod.GET)
    @ApiOperation(value = "police监测中符合规则的和不符合规则的对比柱状图policy_result字段", notes = "police监测中符合规则的和不符合规则的对比柱状图policy_result字段")
    public Map<String, Object> policyCheck() {
        return dataService.policyCheck();
    }
}
